package org.light.datamill.core;

import org.light.domain.Domain;
import org.light.domain.ManyToMany;
import org.light.domain.Project;

public class DataMill {
	public void createDatabase(Project project) {
		
	}
	
	public String createTable(Domain domain) throws Exception{
		String sql = "";
		if ("MariaDB".equalsIgnoreCase(domain.getDbType())||"MySQL".equalsIgnoreCase(domain.getDbType())) {
			sql = MariaDBReflector.generateTableDefinition(domain);
		}
		return sql;
	}
	
	public String createLinkTable(ManyToMany mtm) throws Exception{
		String sql = "";
		if ("MariaDB".equalsIgnoreCase(mtm.getMaster().getDbType())||"MySQL".equalsIgnoreCase(mtm.getMaster().getDbType())) {
			sql = MariaDBReflector.generateLinkTableDefinition(mtm.getMaster(), mtm.getSlave());
		}
		return sql;
	}
	
	public String createInsertStatement(Domain dataDomain) throws Exception{
		String sql = "";
		if ("MariaDB".equalsIgnoreCase(dataDomain.getDbType())||"MySQL".equalsIgnoreCase(dataDomain.getDbType())) {
			sql = MariaDBReflector.generateInsertSqlWithValue(dataDomain);
		}
		return sql;
	}
	
	public String createLinkTableInsertStatement(ManyToMany dmtm) throws Exception{
		String sql = "";
		if ("MariaDB".equalsIgnoreCase(dmtm.getMaster().getDbType())||"MySQL".equalsIgnoreCase(dmtm.getMaster().getDbType())) {
			sql = MariaDBReflector.generateMtmInsertSqlWithValues(dmtm);
		}
		return sql;
	}
}
